package IOperator;

import Book.*;
import java.util.Scanner;
public class FindBooks implements IOperator{
    @Override
    public void work(Bookshelf bookshelf) {
        System.out.println("查找图书!");
        System.out.print("请输入你要查找的图书:# ");
        Scanner scanner = new Scanner(System.in);
        String bookName = scanner.nextLine();

        int currCount = bookshelf.getBooksNumber();
        for(int i=0;i<currCount;i++){
            Book book = bookshelf.getBooks(i);
            if(bookName.equals(book.getName())){
                System.out.println("成功找到《"+bookName+"》!");
                System.out.println(book);
                return;
            }
        }
        System.out.println("找不到《"+bookName+"》!");
    }
}
